package com.taikang.hmp.hbusiness.doctor.information.action.intface;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.taikang.hmp.frame.common.TKException;
import com.taikang.hmp.frame.common.datastructre.Dto;
import com.taikang.hmp.frame.common.datastructre.support.BaseDto;
import com.taikang.hmp.frame.common.datastructre.support.ResponseDto;
import com.taikang.hmp.frame.common.web.action.BaseAction;
import com.taikang.hmp.hbusiness.doctor.information.service.InformationService;



public class InformationAction extends BaseAction{
	
	
	private static Logger logger = LoggerFactory.getLogger(InformationAction.class);
	
	
	private InformationService informationService;
	
	

	@Override
	public String executeAction() {
		// TODO Auto-generated method stub
       if ("getInformationList".equals(requestDto.getMethod())) {
			
			logger.info("--获取药品列表: getInformationList method --");
			return getInformationList();
		}else if ("saveInformation".equals(requestDto.getMethod())) {
			
			logger.info("--保存用药计划: saveMedicinePlan method --");
			return saveInformation();
       
		}
       
       else {
			throw new TKException("no support method:"+requestDto.getMethod());
		}
		
		
		
	}

	
	
	
	/**
	 * 获取药品列表
	 * 
	 * @return
	 */
	public String getInformationList() {
		ResponseDto responseDto = new ResponseDto();
		List<Dto> resultList = informationService.getInformationList();
		Dto resultDto = new BaseDto();
		resultDto.put("resultlist", resultList);
		responseDto.pushResultDto(resultDto);
		//
		super.setDataMap(responseDto);
		return SUCCESS;
	}
	
	/**
	 * 保存咨询
	 */
	public String saveInformation() {	
		ResponseDto responseDto = new ResponseDto();
		//获取参数
		Dto paramDto = requestDto.getRequestlist().get(0);
		paramDto = super.appendRequestBase(paramDto, requestDto);
		//
		informationService.saveInformation(paramDto);
		//
		super.setDataMap(responseDto);
		return SUCCESS;
	}
	
	
	
	public String deleteInformation() {
		ResponseDto responseDto = new ResponseDto();
		//获取参数
		Dto paramDto = requestDto.getRequestlist().get(0);
		paramDto = super.appendRequestBase(paramDto, requestDto);
		informationService.delInformationList(paramDto);
		super.setDataMap(responseDto);
		return SUCCESS;
	}
	
	
	

	public InformationService getInformationService() {
		return informationService;
	}



	public void setInformationService(InformationService informationService) {
		this.informationService = informationService;
	}

}
